package com.springcloud.order.modular.order.controller;

import com.springcloud.commom.annotion.BusinessLog;
import com.springcloud.commom.enums.LogAnnotionOpTypeEnum;
import com.springcloud.commom.api.R;


import com.springcloud.order.modular.order.service.OrderService;
import com.springcloud.order.param.OrderParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import javax.annotation.Resource;

/**
 * 控制器
 *
 * @author hzl
 * @date 2024-07-30 15:48:28
 */
@RestController
public class OrderController {

    @Resource
    private OrderService orderService;

    /**
     * 查询
     *
     * @author hzl
     * @date 2024-07-30 15:48:28
     */
    @GetMapping("/order/page")
    @BusinessLog(title = "_查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public R page(OrderParam orderParam) {
        return R.data(orderService.page(orderParam));
    }

    /**
     * 添加
     *
     * @author hzl
     * @date 2024-07-30 15:48:28
     */
    @PostMapping("/order/add")
    @BusinessLog(title = "_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public R add(@RequestBody @Validated(OrderParam.add.class) OrderParam orderParam) {
            orderService.add(orderParam);
        return R.success();
    }

    /**
     * 删除
     *
     * @author hzl
     * @date 2024-07-30 15:48:28
     */
    @PostMapping("/order/delete")
    @BusinessLog(title = "_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public R delete(@RequestBody @Validated(OrderParam.delete.class) OrderParam orderParam) {
            orderService.delete(orderParam);
        return R.success();
    }

    /**
     * 编辑
     *
     * @author hzl
     * @date 2024-07-30 15:48:28
     */
    @PostMapping("/order/edit")
    @BusinessLog(title = "_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public R edit(@RequestBody @Validated(OrderParam.edit.class) OrderParam orderParam) {
            orderService.edit(orderParam);
        return R.success();
    }

    /**
     * 查看
     *
     * @author hzl
     * @date 2024-07-30 15:48:28
     */
    @GetMapping("/order/detail")
    @BusinessLog(title = "_查看", opType = LogAnnotionOpTypeEnum.DETAIL)
    public R detail(@Validated(OrderParam.detail.class) OrderParam orderParam) {
        return R.data(orderService.detail(orderParam));
    }

    /**
     * 列表
     *
     * @author hzl
     * @date 2024-07-30 15:48:28
     */
    @GetMapping("/order/list")
    @BusinessLog(title = "_列表", opType = LogAnnotionOpTypeEnum.QUERY)
    public R list(OrderParam orderParam) {
        return R.data(orderService.list(orderParam));
    }

}
